using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Diagnostics;
using IngenEngine;
using IngenEngine.Meshes;
using Microsoft.DirectX;
using Microsoft.DirectX.Direct3D;

namespace UI
{
	public partial class frmIngen : Form
	{
		SceneManager scene;

		public frmIngen()
		{
			InitializeComponent();
			scene = new SceneManager(this);
		}

		//Init and Loading
		protected override void OnLoad(EventArgs e)
		{
			base.OnLoad(e);
			scene.Init();
			scene.Load();
		}

		//Prevents crashing when form is closed directly
		protected override void OnClosing(CancelEventArgs e)
		{
			base.OnClosing(e);
			scene.Running = false;	
		}

		//The game loop
		protected override void OnShown(EventArgs e)
		{
			base.OnShown(e);
			scene.Start();
			this.Close();
		}

		//Keys
		protected override void OnKeyDown(KeyEventArgs e)
		{
			base.OnKeyDown(e);
			if (e.KeyCode == Keys.Escape)
				scene.Running = false;
		}
	}
}